package com.fintecher.service.serviceImpl;

import com.fintecher.dao.IRoleDao;
import com.fintecher.pojo.Role;
import com.fintecher.pojo.User;
import com.fintecher.service.IRoleService;
import com.fintecher.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * Created by Administrator on 2017/2/8.
 */
@Service("roleService")
public class RoleServiceImpl implements IRoleService {
    @Autowired
    private IRoleDao roleDao;

    public int addRole(Role role) {
        int role1 =roleDao.addRole(role);
        return role1;
    }

    /**
     * 查询所有的用户组中的用户
     * @param role
     * @return
     */
    public List<Role> selRoleGroupUser(Role role) {

        List<Role> userList = roleDao.selRoleGroupUser(role);
        return userList;

    }

    /**
     * 删除角色
     * @param id
     * @return
     */
    public boolean delRole(Integer id) {
        if(id != null){
            roleDao.delRole(id);
        }
        return true;
    }
    /**
     * 查询登录账户的所有权限
     * @param role
     * @return
     */
    public List<Role> selAllPower(Role role) {
        List<Role> roleList = roleDao.selAllPower(role);
        return roleList;
    }
    /**
     * 查看本帐号所有的用户组
     * @return
     */
    public List<Role> roleList(User user) {
        List<Role> roleList = roleDao.roleList(user);
        return roleList;
    }
    /**
     * 查看本账号是否有审核权限
     * @param user
     * @return
     */
    public List<Role> describesRole(User user) {
        List<Role> roleList = roleDao.describesRole(user);
        return roleList;
    }


    /**
     * 审核用户组功能/////修改用户组状态
     * @param role
     * @return
     */
    public boolean updateRoleGroup(Role role){
        roleDao.updateRoleGroup(role);
        return true;
    }

    /**
     * 修改角色用户审核人
     * @param role
     * @return
     */
    public boolean updateRoleGroupDes(Role role){
        roleDao.updateRoleGroupDes(role);
        return true;
    }



    public List<Role> sel(Role role){
        List<Role> roleList = roleDao.sel(role);
        return roleList;
    }


    @Override
    public Integer getCount(Integer id) {
        return roleDao.getCount(id);
    }
}
